<?php
 include_once('weixin/PhpQRcode.class.php');
  include_once('weixin/Guid.class.php');
  //define('LOCAL_PIC_PATH','mnt/www/wx/');
class PhpQRcodeAction extends Action{
	public function _initialize(){
		
       $this->retVal = Session::init();
        if (!$this->retVal) {
            Output::instance()->resultCode(code_access_denied);
            exit;
        }
        $this->cid = Session::$user['customerId'];
        $this->guid = new Guid();
        
	}

    /**
     * ������ͨ��ά��
     * @param $url //��ά������
     * @param int $isReturn 1:���� 0:���
     */
	public function create_qcode($url, $isReturn=0){

         // echo $url;
         // exit;

		$url_list = explode(',', $url);
		$qcode_list = array();
	
		foreach ($url_list as $key => $value) {
			$qcode_list[$key]['url'] = $value;
			$fname = $this->guid->newGuid()->toString()."phpQRcode.png";
            if(!is_dir(LOCAL_PIC_PATH)){
                Log::write('111111'.LOCAL_PIC_PATH);
                createDir(LOCAL_PIC_PATH);
                Log::write('222222');
            }
            $fileName= LOCAL_PIC_PATH.$fname;
            // echo $value;
            // exit;
            // ob_clean();
            PhpQRcode::png($value, $fileName, 'L', 9,4);
            $qr_img = $fileName;
			$qcode_list[$key]['qr_img'] = $fileName;

		}
		// header('Content-Type: image/png');

		$result = array();
		$result['code'] = 1;
		$result['qcode_list']  = $qcode_list;
        if($isReturn){
            return $qcode_list;
        }
		// $result['local_pic_path'] = LOCAL_PIC_PATH;
		Output::instance()->object($result);

	}
}